package object.obj2D.graphics;

import javax.microedition.khronos.opengles.GL10;
import system.Graphics;

public class TexSquare extends Square {
	private GL10 gl;
	public TexSquare(float width, float height) {
		super(width , height);
		m_texture = new float[] {
				0.0f,	0.0f,	//0
				1.0f,	0.0f,	//1
				1.0f,	1.0f,	//2
				0.0f,	1.0f	//3
		};
		m_textureBuffer = CreateFloatBuffer(m_texture);
		gl = Graphics.GetGraphics();
	}
	
	public void SetTexCoord(float[] texCoord)
	{
		m_textureBuffer = CreateFloatBuffer(texCoord);
	}
	
	public void Render(){
		gl.glEnable(GL10.GL_TEXTURE_2D);
		gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
		
		gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, m_textureBuffer);
		super.Render();
		
		gl.glDisable(GL10.GL_TEXTURE_2D);
		gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
	}
}
